import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import eslintPlugin from 'vite-plugin-eslint'
import { resolve } from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    eslintPlugin()
  ],
  // 别名
  resolve: {
    alias: {
      '@': resolve(__dirname, './src')
    }
  },
  // 引入全局变量
  css: {
    preprocessorOptions: {
      less: {
        additionalData: '@import "@/styles/variable.less";'
      }
    }
  },
  server: {
    // 配置跨域
    proxy: {
      '/api': {
        target: 'http://localhost:3000',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    },
    // 配置端口号
    port: 8080
  }
})
